home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
351-375
/
359
/
dice
/
dice.lzh
/
lib
/
amiga
/
parseargs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-27
|
886b
|
65 lines
/*
* PARSEARGS.C
*
* (c)Copyright 1990, Matthew Dillon, All Rights Reserved
*/
#include <stdio.h>
/*
* Returns argc for arguments. Does NOT include arg0
*/
int
_parseargs1(copy, len)
char *copy;
int len;
{
int ac = 0;
for (;;) {
while (*copy == ' ' || *copy == 9)
++copy;
if (*copy == 0 || *copy == 0x0A)
break;
++ac;
if (*copy == '\"') {
do {
++copy;
} while (*copy && *copy != '\"');
} else {
while (*copy && *copy != 0x0A && *copy != ' ' && *copy != 9)
++copy;
}
if (*copy == 0)
break;
*copy++ = 0;
}
return(ac);
}
/*
* Dumps 'ac' arguments into av beginning at index 0.
*/
void
_parseargs2(copy, av, ac)
char *copy;
char **av;
int ac;
{
while (ac) {
while (*copy == ' ' || *copy == 9)
++copy;
if (*copy == '\"')
++copy;
*av++ = copy;
while (*copy)
++copy;
++copy;
--ac;
}
}